<?php
defined('IN_IA') or exit ('Access Denied');

class Core extends WeModuleSite
{
  
    public function getMainMenu()
    {
        global $_W, $_GPC;

        $do = $_GPC['do'];
        $navemenu = array();
        $cur_color = ' style="color:#d9534f;" ';
      $account=pdo_get('zh_gjw_account',array('uid'=>$_W['user']['uid']));
		$arr=explode(',',$account['authority']);
      if($_W['isfounder'] || $_W['role'] == 'manager' or $account['role']==2 && in_array("cates", $arr) ){
      
            $navemenu[0] = array(
                'title' => '<a href="index.php?c=site&a=entry&op=display&do=cates&m=zh_gjw" class="panel-title wytitle" id="yframe-0" style="width:132px;"><icon style="color:#8d8d8d;" class="fa fa-server"></icon>分类管理</a>',
                'items' => array(
                    0 => $this->createMainMenu('分类管理', $do, 'cates', ''),
                )
            );
      }
      if($_W['isfounder'] || $_W['role'] == 'manager' or $account['role']==2 && in_array("dblist", $arr) ){ 
            $navemenu[1] = array(
                'title' => '<a href="index.php?c=site&a=entry&op=display&do=dblist&m=zh_gjw" class="panel-title wytitle" id="yframe-1" style="width:132px;"><icon style="color:#8d8d8d;" class="fa fa-life-ring"></icon>抖宝管理</a>',
                'items' => array(
                    // 0 => $this->createMainMenu('抖宝分类', $do, 'dbcate', ''),
                    1 => $this->createMainMenu('抖宝列表', $do, 'dblist', ''),
                    2 => $this->createMainMenu('评论管理', $do, 'dbassess', ''),
                    3 => $this->createMainMenu('视频管理', $do, 'isvideo', ''),
                )
            );
      }
        if($_W['isfounder'] || $_W['role'] == 'manager' or $account['role']==2 && in_array("shotmanage", $arr) ){     
            $navemenu[2] = array(
                'title' => '<a href="index.php?c=site&a=entry&op=display&do=shotmanage&m=zh_gjw" class="panel-title wytitle" id="yframe-2" style="width:132px;"><icon style="color:#8d8d8d;" class="fa fa-money"></icon>微拍管理</a>',
                'items' => array(
                    // 0 => $this->createMainMenu('微拍分类', $do, 'shotcate', ''),
                    1 => $this->createMainMenu('微拍管理', $do, 'shotmanage', ''),
                    // 2 => $this->createMainMenu('评论管理', $do, 'shotassess', ''),
                    //3 => $this->createMainMenu('费用设置', $do, 'shotmoney', ''),
                    4 => $this->createMainMenu('拍卖规则', $do, 'shotrule', ''),
                    //5 => $this->createMainMenu('拍卖时间', $do, 'shottime', ''),
                )
            );
        }
       if($_W['isfounder'] || $_W['role'] == 'manager' or $account['role']==2 && in_array("marketmanage", $arr) ){   
            $navemenu[3] = array(
                'title' => '<a href="index.php?c=site&a=entry&op=display&do=marketmanage&m=zh_gjw" class="panel-title wytitle" id="yframe-3" style="width:132px;"><icon style="color:#8d8d8d;" class="fa fa-recycle"></icon>地摊管理</a>',
                'items' => array(
                    // 0 => $this->createMainMenu('地摊分类', $do, 'marketcate', ''),
                    1 => $this->createMainMenu('地摊管理', $do, 'marketmanage', ''),
                    // 2 => $this->createMainMenu('评论管理', $do, 'marketassess', ''),
                    //3 => $this->createMainMenu('费用设置', $do, 'marketmoney', ''),
                    4 => $this->createMainMenu('地摊规则', $do, 'marketrule', ''),
                )
            );
       }   
      
      if($_W['isfounder'] || $_W['role'] == 'manager' or $account['role']==2 && in_array("storemanage", $arr) ){  
            $navemenu[9] = array(
                'title' => '<a href="index.php?c=site&a=entry&op=display&do=storemanage&m=zh_gjw" class="panel-title wytitle" id="yframe-9" style="width:132px;"><icon style="color:#8d8d8d;" class="fa fa-cubes"></icon>商城管理</a>',
                'items' => array(
                    // 0 => $this->createMainMenu('地摊分类', $do, 'marketcate', ''),
                    1 => $this->createMainMenu('商城管理', $do, 'storemanage', ''),
                    // 2 => $this->createMainMenu('评论管理', $do, 'marketassess', ''),
                    //3 => $this->createMainMenu('费用设置', $do, 'marketmoney', ''),
                    //4 => $this->createMainMenu('地摊规则', $do, 'marketrule', ''),
                )
            );
      }
     if($_W['isfounder'] || $_W['role'] == 'manager' or $account['role']==2 && in_array("primanage", $arr) ){  
            $navemenu[4] = array(
                'title' => '<a href="index.php?c=site&a=entry&op=display&do=primanage&m=zh_gjw" class="panel-title wytitle" id="yframe-4" style="width:132px;"><icon style="color:#8d8d8d;" class="fa fa-pencil-square-o"></icon>定制管理</a>',
                'items' => array(
                    // 0 => $this->createMainMenu('定制分类', $do, 'pricate', ''),
                    1 => $this->createMainMenu('帖子管理', $do, 'primanage', ''),
                    // 2 => $this->createMainMenu('评论管理', $do, 'priassess', ''),
                    //3 => $this->createMainMenu('费用设置', $do, 'primoney', ''),
                )
            );
     }
       if($_W['isfounder'] || $_W['role'] == 'manager' or $account['role']==2 && in_array("register", $arr) ){   
            $navemenu[5] = array(
                'title' => '<a href="index.php?c=site&a=entry&op=display&do=register&m=zh_gjw" class="panel-title wytitle" id="yframe-5" style="width:132px;"><icon style="color:#8d8d8d;" class="fa fa-user"></icon>用户管理</a>',
                'items' => array(
                    // 0 => $this->createMainMenu('游客管理', $do, 'visit', ''),
                    1 => $this->createMainMenu('用户管理', $do, 'register', ''),
                )
            );
       }
        if($_W['isfounder'] || $_W['role'] == 'manager' or $account['role']==2 && in_array("cusmanage", $arr) ){   
            $navemenu[6] = array(
                'title' => '<a href="index.php?c=site&a=entry&op=display&do=cusmanage&m=zh_gjw" class="panel-title wytitle" id="yframe-6" style="width:132px;"><icon style="color:#8d8d8d;" class="fa fa-globe"></icon>商家管理</a>',
                'items' => array(
                    // 0 => $this->createMainMenu('商家分类', $do, 'cuscate', ''),
                    1 => $this->createMainMenu('商家管理', $do, 'cusmanage', ''),
                    2 => $this->createMainMenu('商家信用保证金', $do, 'reputationrecords', ''),
                )
            );
        }
      if($_W['isfounder'] || $_W['role'] == 'manager' or $account['role']==2 && in_array("orders", $arr) ){   
            $navemenu[7] = array(
                'title' => '<a href="index.php?c=site&a=entry&op=display&do=orders&m=zh_gjw" class="panel-title wytitle" id="yframe-7" style="width:132px;"><icon style="color:#8d8d8d;" class="fa fa-bars"></icon>订单管理</a>',
                'items' => array(
                    0 => $this->createMainMenu('营业概览', $do, 'orders', ''),
                    1 => $this->createMainMenu('订单列表', $do, 'orderlist', ''),
                    // 2 => $this->createMainMenu('售后订单', $do, 'orderselt', ''),
                    3 => $this->createMainMenu('评分管理', $do, 'orderassess', ''),
                )
            );
      }
     if($_W['isfounder'] || $_W['role'] == 'manager' or $account['role']==2 && in_array("applymoney", $arr) ){  
            $navemenu[8] = array(
                'title' => '<a href="index.php?c=site&a=entry&op=display&do=applymoney&m=zh_gjw" class="panel-title wytitle" id="yframe-8" style="width:132px;"><icon style="color:#8d8d8d;" class="fa fa-university"></icon>财务管理</a>',
                'items' => array(
                    // 0 => $this->createMainMenu('保证金管理', $do, 'moneymanage', ''),
                    1 => $this->createMainMenu('提现管理', $do, 'applymoney', ''),
                    2 => $this->createMainMenu('提现设置', $do, 'moneyset', ''),
                )
            );
     }
      if($_W['isfounder'] || $_W['role'] == 'manager' or $account['role']==2 && in_array("peiz", $arr) ){  
            $navemenu[14] = array(
                'title' => '<a href="index.php?c=site&a=entry&op=display&do=peiz&m=zh_gjw" class="panel-title wytitle" id="yframe-14"><icon style="color:#8d8d8d;" class="fa fa-cog"></icon>  系统设置</a>',
                'items' => array(
                    // 0 => $this->createMainMenu('基本信息 ', $do, 'system', ''),
                    1 => $this->createMainMenu('小程序配置', $do, 'peiz', ''),
                    2 => $this->createMainMenu('支付配置', $do, 'pay', ''),
                    3 => $this->createMainMenu('短信配置', $do, 'code', ''),
                    4 => $this->createMainMenu('模板消息', $do, 'templeid', ''),                      
                    5 => $this->createMainMenu('帮助中心设置', $do, 'help', ''),
                    6 => $this->createMainMenu('联系客服设置', $do, 'serphone', ''),   
                    7 => $this->createMainMenu('LOGO设置', $do, 'logo', ''), 
                    8 => $this->createMainMenu('费用管理', $do, 'dbmoney', ''), 
                    9 => $this->createMainMenu('初始评级设置', $do, 'ucgrade', ''),
                    10 => $this->createMainMenu('用户评级设置', $do, 'usergrade', ''),
                    11 => $this->createMainMenu('用户系统保证金', $do, 'sysbzj', ''),
                    12 => $this->createMainMenu('商家评级设置', $do, 'storegrade', ''),
                    13 => $this->createMainMenu('商家信用保证金', $do, 'reputation', ''),
                    14 => $this->createMainMenu('账号管理', $do, 'zhanghao', ''),
                )
            );
      }
            
        
        return $navemenu;
    }
    public function getNaveMenu($storeid='', $action='')
    {
        global $_W, $_GPC;
        $do = $_GPC['do'];
        $navemenu = array();
        $cur_color = '#8d8d8d';
        $navemenu[1] = array(
            'title' => '<a href="zh_gjw.php?c=site&a=entry&do=cusdata&m=zh_gjw" class="panel-title wytitle" id="yframe-1"><icon style="color:#8d8d8d;" class="fa fa-bars"></icon>营业概览</a>',
            'items' => array(
                 0 => $this->createSubMenu('营业概览 ', $do, 'cusdata', 'fa-angle-right', $cur_color,''),
            )
        );
        $navemenu[2] = array(
            'title' => '<a href="zh_gjw.php?c=site&a=entry&do=cusorder&m=zh_gjw" class="panel-title wytitle" id="yframe-2"><icon style="color:#8d8d8d;" class="fa fa-pencil-square-o"></icon>  订单管理</a>',
            'items' => array(
                0 => $this->createSubMenu('订单列表', $do, 'cusorder', 'fa-angle-right', $cur_color,''),
            )
        );
        $navemenu[3] = array(
            'title' => '<a href="zh_gjw.php?c=site&a=entry&do=cuslatlng&m=zh_gjw" class="panel-title wytitle" id="yframe-3"><icon style="color:#8d8d8d;" class="fa fa-pencil-square-o"></icon>  商家展示</a>',
            'items' => array(
                0 => $this->createSubMenu('商家展示', $do, 'cuslatlng', 'fa-angle-right', $cur_color,''),
            )
        );
        return $navemenu;
    }

    function createCoverMenu($title, $method, $op, $icon = "fa-image", $color = '#d9534f')
    {
        global $_GPC, $_W;
        $cur_op = $_GPC['op'];
        $color = ' style="color:'.$color.';" ';
        return array('title' => $title, 'url' => $op != $cur_op ? $this->createWebUrl($method, array('op' => $op)) : '',
            'active' => $op == $cur_op ? ' active' : '',
            'append' => array(
                'title' => '<i class="fa fa-angle-right"></i>',
            )
        );
    }

    function createMainMenu($title, $do, $method, $icon = "fa-image", $color = '')
    {
        $color = ' style="color:'.$color.';" ';

        return array('title' => $title, 'url' => $do != $method ? $this->createWebUrl($method, array('op' => 'display')) : '',
            'active' => $do == $method ? ' active' : '',
            'append' => array(
                'title' => '<i '.$color.' class="fa fa-angle-right"></i>',
            )
        );
    }

    function createSubMenu($title, $do, $method, $icon = "fa-image", $color = '#d9534f', $storeid)
    {
        $color = ' style="color:'.$color.';" ';
        $url = $this->createWebUrl($method, array('op' => 'display', 'storeid' => $storeid));
        if ($method == 'stores') {
            $url = $this->createWebUrl('stores', array('op' => 'post', 'id' => $storeid, 'storeid' => $storeid));
        }

        return array('title' => $title, 'url' => $do != $method ? $url : '',
            'active' => $do == $method ? ' active' : '',
            'append' => array(
                'title' => '<i class="fa '.$icon.'"></i>',
            )
        );
    }


    function createWebUrl2($do, $query = array()) {
        $query['do'] = $do;
        $query['m'] = strtolower($this->modulename);
      
        return $this->wurl('site/entry', $query);
    }

    function wurl($segment, $params = array()) {
      
        list($controller, $action, $do) = explode('/', $segment);
        $url = './zh_gjw.php?';
        if (!empty($controller)) {
            $url .= "c={$controller}&";
        }
        if (!empty($action)) {
            $url .= "a={$action}&";
        }
        if (!empty($do)) {
            $url .= "do={$do}&";
        }
        if (!empty($params)) {
            $queryString = http_build_query($params, '', '&');
            $url .= $queryString;
        }
        return $url;
    }

    


    public function set_tabbar($action, $storeid)
    {
        $actions_titles = $this->actions_titles;
        $html = '<ul class="nav nav-tabs">';
        foreach ($actions_titles as $key => $value) {
            if ($key == 'stores') {
                $url = $this->createWebUrl('stores', array('op' => 'post', 'id' => $storeid));
            } else {
                $url = $this->createWebUrl($key, array('op' => 'display', 'storeid' => $storeid));
            }

            $html .= '<li class="' . ($key == $action ? 'active' : '') . '"><a href="' . $url . '">' . $value . '</a></li>';
        }
        $html .= '</ul>';
        return $html;
    }
}